
//
// 110528 - AH - Created.
//

package org.soekrat.engine.forest;

import org.soekrat.engine.ontology.Sentence;
import org.soekrat.engine.ontology.SentenceBasedOntology;

/**
 * <p>
 *   {@link Sentence} for the
 *   {@link Forest}
 *   {@link SentenceBasedOntology}.
 * </p>
 * @author Arne Halvorsen (AH)
 * @author Laetitia Le Chatton (LLC)
 */
public final class ForestSentence implements Sentence 
{
  private final Tree[] m_path;
  
  private final String m_text;
  
  /**
   * <p>
   *   Constructor.
   * </p>
   * @param path {@link #getPath()}.
   */
  ForestSentence(Tree[] path)
  {
    if (path==null)
    {
      throw new NullPointerException("path");
    }
    
    m_path=path;
    
    StringBuilder sb=new StringBuilder();
    boolean first=true;
    for (Tree tree : path) 
    {
      if (!first) sb.append(' ');
      first=false;
      sb.append(tree.getName());
    }
    m_text=sb.toString();
  }
  
  @Override
  public String toString(){ return m_text; }
  
  /**
   * <p>
   *   Gets path that defines this sentence.
   * </p>
   * @return Path.
   */
  Tree[] getPath(){ return m_path; }
  
}
